#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>




/*int Add(int x, int y) {
	int z = 0;
	z = x + y;
	return z;
}

int main()
{
	int a = 0;
	int b = 0;
	scanf("%d %d", &a, &b);
	int ret = Add(a, b);
		printf("%d", ret);
	return 0;
}*/


int is_leap_year(int y) {
	if ((y % 4 == 0) && (y % 100 != 0) || (y % 400 == 0)) {
		return 1;
	}
	else
		return 0;
}


int The_day_is(int x, int y) {
	int d[] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
	int day = d[y];
	if  (is_leap_year(y)==1&&y==2);
	day++;
	return day;

}


int main()
{
	int year = 0;
	int month = 0;
	scanf("%d %d", year, month);
	int days = The_day_is(year, month);
	printf("%d", days);
	return 0;
}
